
<?php
//模块插件类
//对外接口函数类，其他插件可通过“$this->plugin('模块名称')->方法名” 来调用本类的方法
defined('BY_JYA') or exit('error');
class func_jy_heweather extends plugin{
	public function getsetting(){
		$setting=$this->get_setting();	
		return $setting;
	}
	public function getweather($location,$type='now'){
		$setting=$this->get_setting();
		$setting['hefeng_key']=$setting['hefeng_key']?:'023788fdbff4436a8825510d52eaf0eb';
		$setting['baidu_key']=$setting['baidu_key']?:'5slgyqGDENN7Sy7pw29IUvrZ';
		if($setting['type']==2){
			$url = "https://api.map.baidu.com/telematics/v3/weather?output=json&location=".$location."&key=".$setting['baidu_key'];
		}else{
			$url = "https://free-api.heweather.net/s6/weather/".$type."??location=".$location."&key=".$setting['hefeng_key'];
		}
		$data = cfc('http')->ihttp_request($url);
		$content=$data['content'];
		$weather=json_decode($content,true);
		return $weather;
	}
}
?>
